﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

using Xc.DataAccess.Core;

namespace Xc.DataAccess.AepCoapCore.Models
{
    public enum Plantform
    {
        电信 = 03 | 05 | 11,
        移动 = 00 | 02 | 04 | 07,
        联通 = 01 | 06 | 09,
        铁通 = 20,
        未知 = 0xFF
    }

    public class AddDeviceModel:ViewModelBase
    {

        /// <summary>
        /// 平台
        /// </summary>
        [JsonIgnore()]
        public Plantform Plantform
        {
            get
            {
                if (string.IsNullOrEmpty(IMSI))
                {
                    return Plantform.未知;
                }
                var text = IMSI.Substring(3, 2);
                if (int.TryParse(text, out var n))
                {
                    Plantform plantform=new Plantform();
                    switch (n)
                    {
                        case 3:
                        case 5:
                        case 11:plantform = Plantform.电信;break;

                        case 0:
                        case 2:
                        case 4:
                        case 7:
                            plantform = Plantform.移动; break;
                        case 1:
                        case 6:
                        case 9:
                            plantform = Plantform.联通; break;
                        case 20:
                            plantform = Plantform.铁通; break;
                        default:
                            break;
                    }
                    return plantform;
                }
                else
                {
                    return Plantform.未知;
                }
            }
        }
        private string _AddDeviceStatus { get; set; }
        public string DeviceNumber { get; set; }
        public string IMSI { get; set; }
        public string IMEI { get; set; }
        public string ICCID { get; set; }
        public string ProductTime { get; set; }

        public string AddDeviceStatus
        {
            get
            {
                return _AddDeviceStatus;
            }
            set
            {

                _AddDeviceStatus = value;
                RaisedPropertyChanged();
            }
        }

        public DateTime CreateTime
        {
            get
            {
                if (string.IsNullOrEmpty(ProductTime))
                {
                    return DateTime.MinValue;
                }
                else
                {
                    var time = Convert.ToDateTime(ProductTime);
                    return time;
                }
              
            }
        }

    }
}
